<template>
    <h2>会员等级修改</h2>
    <table class="table table-bordered">
        <tr>
            <td>会员等级名称</td>
            <td>
                <input type="text" placeholder="请输入会员等级名称" v-model="Info.name">
            </td>
        </tr>
        <tr>
            <td>会员等级状态</td>
            <td>
                <input type="radio"  value="true" v-model="Info.state">是
                <input type="radio"  value="false"  v-model="Info.state">否
                
            </td>
        </tr>
        <tr>
            <td>最大成长值</td>
            <td>
                <input type="text" placeholder="请输入最大成长值" v-model="Info.maxpoint">
            </td>
        </tr>
        <tr>
            <td>最小成长值</td>
            <td>
                <input type="text" placeholder="请输入最小成长值" v-model="Info.minpoint">
            </td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;">
                <input type="button" value="修改" @click="add" class="btn btn-primary">
            </td>
            
        </tr>
    </table>
</template>

<script setup lang="ts">
import axios from 'axios';
import {ref,onMounted} from 'vue'
import { useRouter,useRoute } from 'vue-router';
//创建路由实例
const router=useRouter();
const route=useRoute()
//声明响应式数据
const Info=ref({
    id:route.params.id,
  name: "",
  state: true,
  maxpoint: "",
  minpoint: ""
})
onMounted(()=>{
    fan();
})
const fan = ()=>
{
    axios.get("https://localhost:44376/api/Grade/FindShwo?",{
        
        params:{
            id:route.params.id
        
        }
        
        
    })
    .then
    (
        res=>
        {
            Info.value = res.data
        }
    )
}
const add = ()=>
{

    axios.put("https://localhost:44376/api/Grade/Update",Info.value)
    .then
    (
        res=>
        {
            if(res.data > 0)
            {
                alert("修改成功");
                router.push("/GradeShow")
            }
            else
            {
                alert("修改失败");
            }
        }
    )
}
</script>